package com.lingxu.base.system.orgManage.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lingxu.base.system.manage.entity.SysOrg;
import com.lingxu.base.system.manage.entity.SysUser;
import com.lingxu.base.system.orgManage.model.SysOrgCompany;
import com.lingxu.base.system.orgManage.vo.ParentTree;
import com.lingxu.base.system.orgManage.vo.SuperviseVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * @Title: SystemOrgManageMapper
 * @Package: com.lingxu.base.system.orgManage.mapper
 * @Author: ysj闫世杰
 * @Email: 1105324813@qq.com
 * @Date: Created in 2022/3/1 15:00
 * @Description:
 * @Version: 1.0.0
 */
@Mapper
public interface SystemOrgManageMapper {

    /**
     * @Author ysj闫世杰
     * @Description 查询地区
     * @Date 2022/3/3 14:47
     * @Param: code
     * @return java.util.List<java.util.Map>
     **/
    List<Map> findAreaByCode(String code) throws Exception;

    /**
     * @Author ysj闫世杰
     * @Description 查询父id
     * @Date 2022/4/13 17:33
     * @Param: id
     * @return java.lang.String
     **/
    String findParentId(String id) throws Exception;

    String findAreaName(String id) throws Exception;
    /**
     * @Author ysj闫世杰
     * @Description 查询所有的单位名称
     * @Date 2022/3/7 17:54
     * @Param:
     * @return java.util.List<java.util.Map>
     **/
    List<Map> findAllOrg() throws Exception;

    /**
     * @Author ysj闫世杰
     * @Description 新增单位部门信息
     * @Date 2022/3/1 15:51
     * @Param: sysOrg
     * @return void
     **/
    void addNewOrganizeData(SysOrg sysOrg);

    /**
     * @Author ysj闫世杰
     * @Description 查询树形结构
     * @Date 2022/3/2 10:08
     * @Param: id
     * @return java.util.List<com.lingxu.base.system.orgManage.vo.ParentTree>
     **/
    List<ParentTree> findOrgManageTree(String id) throws Exception;
    List<ParentTree> findChildTree(String id) throws Exception;


    List<ParentTree> findOrgManagePersonTree(String id) throws Exception;
    List<ParentTree> findChildPersonTree(String id) throws Exception;

    List<SysOrg> findChildOrg(String id) throws Exception;
    Page<SysUser> findOrgManagePersonList(IPage<SysUser> pageInfo,String id) throws Exception;


    /**
     * @Author ysj闫世杰
     * @Description 修改单位部门信息
     * @Date 2022/3/2 10:08
     * @Param: sysOrg
     * @return int
     **/
    int updateOrganizeData(SysOrg sysOrg) throws Exception;

    /**
     * @Author ysj闫世杰
     * @Description 根据id查询单位信息
     * @Date 2022/3/2 11:06
     * @Param: id
     * @return java.util.Map
     **/
    Map findOrganizeDataById(String id) throws Exception;

    /**
     * @Author ysj闫世杰
     * @Description 查询存在子节点
     * @Date 2022/3/3 17:43
     * @Param: pid
     * @return java.lang.Integer
     **/
    Integer findChildNodes(String pid) throws Exception;
    Integer findUserByOrgId(String id) throws Exception;

    /**
     * @Author ysj闫世杰
     * @Description 删除单位信息
     * @Date 2022/3/2 10:33
     * @Param: id
     * @return int
     **/
    int deleteOrganizeData(String id) throws Exception;


    /**
     * @Author ysj闫世杰
     * @Description 查询部门列表
     * @Date 2022/6/16 19:02
     * @Param: pageInfo
     * @Param: id
     * @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.lingxu.base.system.manage.entity.SysOrg>
     **/
    Page<SysOrg> findChildOrgList(@Param("pageInfo") IPage<SysOrg> pageInfo,@Param("id")String id) throws Exception;

    /**
     * @Author ysj闫世杰
     * @Description 部门关联监督单位
     * @Date 2022/6/17 15:11
     * @Param: sysOrgCompany
     * @return void
     **/
    void addOrgCompanyData(List<SysOrgCompany> sysOrgCompany) throws Exception;

    /**
     * @Author ysj闫世杰
     * @Description
     * @Date 2022/6/22 9:35
     * @Param: id
     * @return java.util.List<com.lingxu.base.system.orgManage.model.SysOrgCompany>
     **/
    List<SuperviseVO> findSuperviseCompanyList(String id) throws Exception;

    /**
     * @Author ysj闫世杰
     * @Description 删除组织关联的监督单位
     * @Date 2022/6/22 11:43
     * @Param: id
     * @return void
     **/
    void deleteSupervise(String id);

    /**
     * @Author ysj闫世杰
     * @Description 查询监督单位名称
     * @Date 2022/6/22 18:05
     * @Param: supId
     * @return java.lang.String
     **/
    String findName(String supId);

    /**
     * @Author ysj闫世杰
     * @Description 查询最大sort值
     * @Date 2022/6/30 15:30
     * @Param:
     * @return int
     **/
    int findMaxSortValue();

    /**
     * 上移
     * @param sort
     * @return
     */
    SysOrg moveUp(Integer sort);

    /**
     *  下移
     * @param sort
     * @return
     */
    SysOrg moveDown(Integer sort);

    /**
     * @Author ysj闫世杰
     * @Description 更新位置下标
     * @Date 2022/6/29 15:39
     * @Param: id
     * @Param: sort
     * @return int
     **/
    int updateSort(@Param("id") String id, @Param("sort") int sort);


    SysOrg selectById(String id);
}
